package connect;




import org.apache.http.client.methods.HttpPost;

import android.util.Log;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;

/**
 * Created by chenyangsb on 2016/4/13.
 */
public class ConNect {
        private  final static  String URIVAR = "http://192.168.1.108:8080/app/";
        public  HttpURLConnection getconnect(String urlpath) {
            String finalurl=URIVAR + urlpath;
            HttpURLConnection connection = null;
            try {
                URL url=new URL(finalurl);
                connection=(HttpURLConnection) url.openConnection();
                connection.setDoInput(true);  //允许输入流
                connection.setDoOutput(true); //允许输出流
                connection.setUseCaches(false);  //不允许使用缓存
                connection.setRequestMethod("POST");  //请求方式
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return connection;
    }
    public static HttpPost gethttppost(String urlpath){
    	String finalurl=URIVAR + urlpath;
        HttpPost httpPost=new HttpPost(finalurl);
        Log.e("dizhi", finalurl);
        return httpPost;
}

    public  HttpURLConnection getconnectmap(String urlpath) {
        String finalurl=urlpath;
        HttpURLConnection connection = null;
        try {
            URL url=new URL(finalurl);
            connection=(HttpURLConnection) url.openConnection();
            connection.setDoInput(true);  //允许输入流
            connection.setDoOutput(true); //允许输出流
            connection.setUseCaches(false);  //不允许使用缓存
            connection.setRequestMethod("POST");  //请求方式
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return connection;
}
        }
